//
//  HYTextField.m
//  Object-CPlayGround
//
//  Created by 韩丛旸 on 16/8/3.
//  Copyright © 2016年 韩丛旸. All rights reserved.
//

#import "HYTextField.h"

@interface HYTextField ()

@property (nonatomic, assign) CheckType checkType;

@end

@implementation HYTextField

- (instancetype)initWithType:(CheckType)type
{
    self = [super init];
    
    if (self)
    {
        self.checkType = type;
    }
    
    return self;
    
}

- (NSString *)checkContentText
{
    switch (self.checkType) {
        case CheckTypePassword:
        {
            NSString *regular = @"^(?![0-9]+$)(?![a-zA-Z]+$)[0-9A-Za-z]{8,16}$";
            NSPredicate *passwordFormatCheckPrdicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regular];
            if (![passwordFormatCheckPrdicate evaluateWithObject:self.text]) {
                return @"密码格式不对";
            }
        }
            break;
            
        default:
            break;
    }
    
    return @"";
}

@end
